Shadowing Dynamic Volumetric Media

ABSTRACT

A dynamic volumetric medium, such as hair, fog, or smoke, may be represented, for purposes of shadow mapping, by transmittance versus depth data for that medium. In one embodiment, the representation may take the form of a plot of transmittance versus depth, with nodes where the transmittance changes non-live linearly with respect of depth into the medium. The number of nodes in the representation may be reduced to reduce memory footprint and to enable the storage of the representation on the same chip doing the shadow mapping. In some embodiments, the number of nodes may be reduced, one node at a time, by removing the node whose underlying trapezoid has the least area of all the remaining nodes.

BACKGROUND

This relates generally to graphics processing and particularly to shadowing dynamic volumetric media.

Dynamic volumetric media are objects that have variable volumes, variable light transmittance, and self-shadowing. Self-shadowing is the effect of an object that creates shadows within itself. Examples of dynamic volumetric media include hair and translucent media such as smoke, dust, glass and fog.

Realistic lighting of dynamic volumetric media adds significant richness and realism to rendered scenes. The self-shadowing created by dynamic volumetric media provides important visual cues that define the shape and structure of that media. Computing self-shadowing in dynamic volumetric media involves accumulating partial occlusion between visual points and light sources in a scene. Accumulating partial occlusion involves capturing the effect of all of the volumetric objects between two points and is generally much more expensive in terms of computing cycles than computing shadows generated by opaque surfaces.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flow chart for one embodiment of the present invention;

FIG. 2 is a depiction of the simplification of transmittance as a function of depth curves during shadow mapping according to one embodiment of the present invention;

FIG. 3 is a flow chart for lossy compression according to one embodiment of the present invention;

FIG. 4 is a flow chart for rasterization according to one embodiment of the present invention; and

FIG. 5 is a hardware depiction for one embodiment of the present invention.

DETAILED DESCRIPTION

Shadow maps may be created for dynamic volumetric media as part of the process of rasterization during graphics processing. The shadow maps may be used for example in connection with video games but the present invention is in no way limited to any particular application.

Approximate volumetric shadows can be computed for real-time applications such as games where predictable performance and a fixed, small memory footprint are desirable. Scattering effects may be ignored in some embodiments and an adaptively sampled representation of volumetric transmittance may be created. The adaptively sampled representation may include texels that store a compact representation of the transmittance curve along a corresponding light ray. The representation can capture and combine transmittance data from arbitrary dynamic occluders, including combining soft media like smoke and very localized and denser media like hair.

In some embodiments a lossy compression algorithm is capable of building a constant storage, variable error representation of visibility while the volume is rendered from the light's point of view. This algorithm may use a variable amount of memory proportional to the total number fragments generated during rasterization. Thus a software rendering pipeline amenable to using variable amounts of memory may overcome these limitations in streaming applications in some embodiments.

Adaptive volumetric shadow maps may encode the fraction of visible light from a light source over an interval as a function of the depth at each texel. This quantity, the transmittance, t, is defined as:

t(z)=e ^(−∫) ⁰ ^(Z) ^(f(x)dx)   (1)

where f (x) is an attenuation function that represents the amount of light absorbed along a light ray.

Referring to FIG. 2, two plots of transmittance versus depth are depicted. The curve on the left shows a graph of transmittance as a function of depth and the curve on the right has been simplified to remove one node. Each node represents a discontinuity in the relationship between transmittance and depth. Two adjacent nodes define a linear segment in one embodiment. Thus the transmittance at each point within the depth of the object is graphed.

In one embodiment each texel stores a fixed size array of irregularly placed samples of the transmittance function in order to limit the amount of memory that must be used. Array elements, in the form of nodes of the approximation, are sorted from front to back along the ray. Each node stores a pair of depth and transmittance values (d_(i), t_(i)). Nodes are adaptively placed at depth and as a result can represent a rich variety of shadow blockers from soft and transmissive particles to sharp and opaque local occluders. The number of nodes stored per texel is a user-defined quantity in some embodiments, where two or more nodes may be stored per texel. Using more nodes allows for a better approximation of transmittance and higher-quality shadows, at the expense of increased storage and computational cost.

Shadow maps may be created by rendering the scene from the light's viewpoint. The shadow maps may handle both opaque objects and objects of variable thickness and density in some embodiments. Specifically, when a non-opaque occluder is rendered and inserted into the shadow map along a ray from the light, the entry and exit points as well as the density along that segment may be recorded as indicated in blocks 12 and 14 in FIG. 1. The transmittance may be integrated over the segment as shown in block 16. Then the integrated transmittance may be composited with transmittance values as indicated in block 18. For example, a segment representing a ray's traversal through a particle may be inserted. For hair, a short segment may be inserted where the light enters and exits the hair strand. For opaque blockers, a short, dense segment may be inserted that takes the transmittance to zero at the exit point.

In any nontrivial scene, the number of light blockers inserted may generate more nodes in the transmittance versus depth curve than it is possible to store in a shadow map texel. In these cases, an on-the-fly lossy compression of transmittance data may be performed to reduce the number of nodes to a maximum node count, which may be user definable, before proceeding with inserting new blockers or after inserting a new blocker and before storing the data back to memory. This procedure may involve many insertion-compression iterations, and so it is desirable to adapt a lossy compression algorithm that is computationally inexpensive while keeping the overall error as small as possible.

In some embodiments only two nodes are removed at a time, corresponding to a single segment insertion, so an algorithm is used that takes as its input an n node curve and generates an n minus one node curve, applying the algorithm repeatedly to remove the desired number of nodes to meet the user specification or a default value for the maximum number of nodes.

In streaming applications, the compression algorithm advantageously does not rearrange node positions. Over many insertion-compression iterations, nodes can drift unpredictably and perform random walks over the compression plane, leading to non-monotonic transmittance curves and introducing artifacts such as overly dark/bright shadows and temporal aliasing. Thus the shadow map algorithm compresses transmittance data simply by removing a node that contributes the least to the overall transmittance curve shape, and the algorithm does not modify node positions, in some embodiments.

Using an area preserving metric to decide which nodes to remove may result in a simple and computationally efficient compression code in some embodiments. Thus referring to FIG. 3, the node that has the least effect on the transmittance versus depth curve area is located as indicated in block 22. In the example of FIG. 2 the node that is removed is denoted A and it is removed because the area of the triangle under the node A is less than the area of the triangle under the node B.

Then the selected node is eliminated as indicated in block 24. A check at diamond 26 determines whether the number of nodes now equals the maximum number of nodes. If so, the transmittance versus depth curve is stored as indicated in block 28. Otherwise, the flow iterates until the number of nodes equals the maximum number of nodes.

In some embodiments area-based metrics are undefined for the first and last node of the curve. Compression may only be applied in internal nodes in some embodiments. This may be beneficial because these uncompressed nodes provide important visual cues such as transition into a volume or the shadows cast from a volume onto opaque surfaces.

Each node of the piecewise transmittance curve maps to an ordered sequence of pairs of depth, transmittance values that encode node depth along the light ray and its associated transmittance. Although transmittance varies exponentially between nodes, linear variation may be assumed in some embodiments to simplify area computations. This simplification allows writing the transmittance integral I_(t) for and N node curve as the sum of N−1 trapezoidal areas:

$I_{t} = {\sum\limits_{i = 0}^{N - 1}\frac{\left( {d_{i + 1} - d_{i}} \right)\left( {t_{i} + t_{i + 1}} \right)}{2}}$

The removal of an internal ith node affects only the area of the two trapezoids that share the nodes. Since the rest of the curve is unaffected, the variation of its integral Δt_(i) may be computed with a simple geometrically derived formula:

Δt _(i)=|(d _(i+1) −d _(i−1))(t _(i+1) −t _(i))−(d _(i+1) −d _(i))(t _(i+1) −t _(i−1))|

Sampling the shadow maps, as indicated in FIG. 3 at block 30, is a generalization of a standard shadow map depth test to soft occluders. The transmittance function may be evaluated at the receiver depth and the process can be repeated over multiple texels, weighting the results according to a specific reconstruction filter in some embodiments.

In view of the irregular nature of the shadow map mapping, filtering may be implemented manually in the shader. For a given texel, a search may be performed over the domain of the curve, as stored, in order to find the two nodes that bound the shadow receiver of depth d, and then interpolating the bounding nodes' transmittance to intercept the shadow receiver.

In some embodiments, the space between nodes may be assumed to exhibit uniform density, which implies the transmittance varies exponentially between each depth interval (see equation 1) (although a linear interpolation may be faster and visually acceptable):

${T(d)} = {t_{l} + {\left( {d - d_{l}} \right)\frac{\left( {t_{r} - t_{l}} \right)}{\left( {d_{r} - d_{l}} \right)}}}$

This procedure may be used as the basis for point filtering in some embodiments. Bilinear filtering is also straightforward: transmittance T(d) is evaluated over four neighboring texels and linearly weighted together.

The shadow mapping may be applied to streaming compression algorithms in some embodiments. Such an implementation may include support for read-modify-write frame buffer operation in the pixel shader. The ability to perform ordered read-modify-write operations is provided in DirectX 11 application program interfaces (APIs) on certain buffer types in the pixel shader. (DirectX 11 is a component of Microsoft Windows). However, the shadow mapping here may to ensure that each pixel's frame buffer memory is modified by only one fragment at a time, in some embodiments.

Because current shader compilers forbid per pixel locks, shadow mapping may be implemented in two different ways. Firstly, a variable memory version may use the current rendering pipeline such as the DIRECTX11 pipeline, by first capturing all fragments and then compressing. Secondly, a truly streaming shadow mapping implementation may use a software particle rasterization pipeline which may be written in DIRECTX 11 Compute-Shader, that supports read-modify-write operations. Other alternatives may also be possible in the present invention is not limited to particular techniques that avoid or use per pixel locks.

The uncompressed solution may include a linked list of light attenuating segments per pixel by using the DIRECTX11 support for atomic gather/scatter memory operations in pixel shaders. All linked lists may be stored in a single buffer, and typically a 20 MBytes buffer is sufficient, in some embodiments. A second pass converts a list of occluding segments at each pixel into a composited transmittance curve—either uncompressed or compressed with shadow mapping or deep shadow map compression algorithms.

The shadow maps may store the transmittance curve in an array of depth/transmittance pairs using two single-precision floating-point values in one embodiment. The entire compressed transmittance curve may fit in an on-chip memory during compression in some embodiments. Depth may be cleared to the far plane value, while transmittance is set to one in order to represent empty space. For example, the number of nodes may be limited to that number which will fit within the available storage within a graphics processing unit (GPU) also performing the rasterization of the dynamic volumetric medium.

Each occluding segment may be inserted by viewing it as a compositing operation between two transmittance curves, respectively representing the incoming blocker and the current transmittance curve. Given two light blockers A and B located along the same light ray, the density function f_(AB)(x) may be written as the sum of the density functions f_(A)(x) and f_(B)(x). Applying equation 1, the total transmittance may be computed:

$\begin{matrix} {{t_{tot}(z)} = ^{- {\int_{0}^{Z}{{f_{AB}\ (x)}{x}}}}} \\ {= {^{- {\int_{0}^{Z}{{f_{A}\ (x)}{x}}}}^{- {\int_{0}^{Z}{{f_{A}\ (x)}{x}}}}}} \\ {= {{t_{A}(Z)}{t_{B}(Z)}}} \end{matrix}$

In the absence of lossy compression, the order of composition is not important in some embodiments. The equation above shows that the resulting total transmittance is given by the product of the two transmittance functions associated with each light blocker. Compression proceeds by removing one node at a time until the maximum node count is reached.

In practice, due to the lossy compression, the order in which the segments are inserted may affect the results. In particular, in a variable-memory implementation, the parallel execution of pixel shaders inserts segments into the linked list in an order that may vary per frame even if the scene and the view are static. Inconsistent ordering can result in visible temporal artifacts, although they are mostly imperceptible and unlikely to be observed when using eight or more nodes or when the volumetric media is moving quickly. In those rare cases when a consistent ordering cannot be preserved and the number of nodes is not sufficient to hide these artifacts, the captured segments may be sorted by depth via insertion sort before inserting them.

Determining the light transmittance at a receiver sample involves reconstructing the transmittance curve at its depth. The two nodes that bound the receiver depth may be located via a fast two-level search. Although this involves searching irregularly spaced nodes, the fact that the representation is stored in fixed size small arrays in some embodiments results in the memory accesses being coherent and local with no variable-length linked list traversals. In fact, the lookup can be implemented entirely with compile time (static) array indexing without dynamic branching, allowing the compiler to keep the entire transmittance curve on-chip, in the graphics processor unit (GPU) registers.

Ordered read-modify-write operations may be implemented on the frame buffer by building a software particle rendering pipeline, for example in a DIRECTX11 ComputeShader. Referring to FIG. 4, the screen may be divided into tiles, as indicated in block 42. Each tile may be assigned to ComputeShader threadgroup, as indicated in block 44. Each threadgroup processes the entire particle set in parallel, building a list of candidate particles that intersect the tile, ordered by primitive identifier, as shown in block 48. The ComputeShader, now parallelizing over pixels instead of particles, runs the shader insertion code for each pixel intersected by a particle, as indicated in block 50. The correct frame buffer update ordering may be enforced by mapping each pixel to a single ComputeShader thread, which may correspond to a single instruction multiple data (SIMD) lane in one embodiment.

In some embodiments, performance improvements may be the result of the use of a streaming compression algorithm that permits direct construction of a compressed transmittance representation without first building the full uncompressed transmittance curve. In addition the use of a small fixed number of nodes such that the entire representation fits into on-chip memory may improve performance in some embodiments. A high-level of performance may be achieved using the curve simplification compression algorithm that supports directly building the compression transmittance function on-the-fly while rendering, in some embodiments. By constraining the compressed curves to use a fixed number of nodes, the curves can stay in on-chip memory during compression, in some embodiments.

The computer system 130, shown in FIG. 5, may include a hard drive 134 and a removable medium 136, coupled by a bus 104 to a chipset core logic 110. A keyboard and mouse 120, or other conventional components, may be coupled to the chipset core logic via bus 108. The core logic may couple to the graphics processor 112, via a bus 105, and the main or host processor 100 in one embodiment. The graphics processor 112 may also be coupled by a bus 106 to a frame buffer 114. The frame buffer 114 may be coupled by a bus 107 to a display screen 118. In one embodiment, a graphics processor 112 may be a multi-threaded, multi-core parallel processor using single instruction multiple data (SIMD) architecture.

In the case of a software implementation, the pertinent code may be stored in any suitable semiconductor, magnetic, or optical memory, including the main memory 132 or any available memory within the graphics processor. Thus, in one embodiment, the code to perform the sequences of FIGS. 1, 3 and 4 may be stored in a non-transitory machine or computer readable medium, such as the memory 132, as indicated at 139, or the graphics processor 112, and may be executed by the processor 100 or the graphics processor 112 in one embodiment.

FIGS. 1, 3 and 4 are flow charts. In some embodiments, the sequences depicted in these flow charts may be implemented in hardware, software, or firmware. In a software embodiment, a non-transitory computer readable medium, such as a semiconductor memory, a magnetic memory, or an optical memory may be used to store instructions and may be executed by a processor to implement the sequences shown in those few charts.

The graphics processing techniques described herein may be implemented in various hardware architectures. For example, graphics functionality may be integrated within a chipset. Alternatively, a discrete graphics processor may be used. As still another embodiment, the graphics functions may be implemented by a general purpose processor, including a multicore processor.

References throughout this specification to “one embodiment” or “an embodiment” mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one implementation encompassed within the present invention. Thus, appearances of the phrase “one embodiment” or “in an embodiment” are not necessarily referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be instituted in other suitable forms other than the particular embodiment illustrated and all such forms may be encompassed within the claims of the present application. 

1. A method comprising: shadow mapping a dynamic volumetric medium by reducing a number of nodes in a representation of transmittance as a function of depth for that medium.
 2. The method of claim 1 including developing a representation of said medium in the form of the transmittance as a function of depth through the medium.
 3. The method of claim 1 including limiting the number of nodes per medium.
 4. The method of claim 3 including limiting the number of nodes such that the representation may be stored in a graphics processor doing the shadow mapping.
 5. The method of claim 1 including selecting nodes to remove based on the area of a trapezoid under each node.
 6. The method of claim 5 including removing nodes one of the time by selecting in each iteration the node having a trapezoid under the node with the least area of all the remaining nodes.
 7. The method of claim 1 including developing a compressed shadow map without first developing an uncompressed shadow map.
 8. A non-transitory computer readable medium storing instructions to perform a sequence comprising: shadow mapping a dynamic volumetric medium by reducing a number of nodes in a representation of transmittance as a function of depth for that medium.
 9. The medium of claim 8 further storing instructions to develop a representation of said medium in the form of the transmittance as a function of depth through the medium.
 10. The medium of claim 8 further storing instructions to limit the number of nodes per medium.
 11. The medium of claim 10 further storing instructions to limit the number of nodes such that the representation may be stored in a graphics processor doing the shadow mapping.
 12. The medium of claim 8 further storing instructions to select nodes to remove based on the area of a trapezoid under each node.
 13. The medium of claim 12 further storing instructions to remove nodes one of the time by selecting in each iteration the node having a trapezoid under the node with the least area of all the remaining nodes.
 14. The medium of claim 8 further storing instructions to develop a compressed shadow map without first developing an uncompressed shadow map.
 15. An apparatus comprising: a processor to shadow map a dynamic volumetric medium by reducing a number of nodes in a representation of transmittance as a function of depth for that medium; and a storage coupled to said processor.
 16. The apparatus of claim 15 wherein said processor is a graphics processing unit.
 17. The apparatus of claim 16 wherein said processor is a single instruction multiple data processor.
 18. The apparatus of claim 15, said processor to limit the number of nodes per medium.
 19. The apparatus of claim 18, said processor to limit the number of nodes such that the representation may be stored in said graphics processor.
 20. The apparatus of claim 15, said processor to remove nodes based on the area of a trapezoid under each node. 